#include <stdio.h>

int main(int argc, char const *argv[])
{
    int inputData = 0;
    int a = 0, b = 0, c = 0, d = 0;
    int changtmp = 0;
    scanf("%d", &inputData);
    //检查4位数
    if ((inputData < 1000) || (inputData > 9999))
    {
        printf("NO FOUR figures\n");
        return 1;
    }
    //翻转
    a = inputData / 1 % 10;
    b = inputData / 10 % 10;
    c = inputData / 100 % 10;
    d = inputData / 1000 % 10;
    //加5
    a += 5;
    b += 5;
    c += 5;
    d += 5;
    //取余
    a %= 10;
    b %= 10;
    c %= 10;
    d %= 10;
    //交换
    changtmp = a;
    a = d;
    d = changtmp;
    //输出
    printf("%d%d%d%d", a, b, c, d);
    return 0;
}
